package com.djinfo.work.dao.impl;

import com.djinfo.work.common.dao.impl.BaseDaoImpl;
import com.djinfo.work.dao.QsDicDao;
import com.djinfo.work.entity.QsDicEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 * @date 2017-06-08 10:48:16
 */
@Repository("QsDicDao")
public class QsDicDaolmpl extends BaseDaoImpl implements QsDicDao {
    @Override
    public void saveOrUpdate(QsDicEntity object) {
        if(null==object.getId()){
            super.save(object);
        }else{
            super.update(object);
        }

    }

    @Override
    public List<QsDicEntity> page(QsDicEntity object, Integer pageNum, Integer pageSize) {
        String hql = " from QsUserEntity where 1=1 ";
        return (List<QsDicEntity>)super.pageQuery( hql,  pageNum,  pageSize);
    }

    @Override
    public List<QsDicEntity> list(QsDicEntity object) {
        String hql = " from QsUserEntity where 1=1 ";
        return (List<QsDicEntity>)super.getList(hql);
    }

    @Override
    public Integer getAllRowCount(QsDicEntity object) {
        String hql = " select count(*) from QsUserEntity where 1=1 ";
        return super.getUniqueObject(hql).hashCode();
    }

    @Override
    public void delete(QsDicEntity object) {
        super.delete(this.selectOne(object));
    }

    @Override
    public QsDicEntity selectOne(QsDicEntity object) {
        return (QsDicEntity)super.get(QsDicEntity.class,object.getId());
    }

    @Override
    public QsDicEntity getById(String id) {
        return (QsDicEntity)super.getByPrimaryKey(QsDicEntity.class, id);
    }
}
